libxenlight: returns errors if xc and/or xs has not been initialized properly.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 8 Jan 2010 11:45:34 +0000 (11:45 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 8 Jan 2010 11:45:34 +0000 (11:45 +0000)
fixed segfault when xenstore or xc are not available.

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
tools/libxl/libxl.c

index 8194623bf6810e5625214a68ccc7d720f61cdaec..a49371540cb97ba7a27ff312f1d8989de425dd8c 100644 (file)
@@ -45,7 +45,17 @@ int libxl_ctx_init(struct libxl_ctx *ctx, int version)
         return ERROR_NOMEM;
 
     ctx->xch = xc_interface_open();
+    if (ctx->xch == -1) {
+        free(ctx->alloc_ptrs);
+        return ERROR_FAIL;
+    }
+
     ctx->xsh = xs_daemon_open();
+    if (!ctx->xsh) {
+        xc_interface_close(ctx->xch);
+        free(ctx->alloc_ptrs);
+        return ERROR_FAIL;
+    }
     return 0;
 }